﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace _反射
{
    class Program
    {
        static void Main(string[] args)
        {

            string s1 = Guid.NewGuid().ToString().ToUpper();
            string s2 = Guid.NewGuid().ToString().ToUpper();

            Person p = new Person();
            p.Id = 1;
            p.Name = "张三";
            p.Sex = "男";
            p.Weight = 65;
            p.Height = 180;
            p.Birthday = DateTime.Now;

            List<Person> pList = new List<Person>();
            pList.Add(p);

            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
            foreach (var Entity in pList)
            {
                Dictionary<string, object> row = new Dictionary<string, object>();
                foreach (PropertyInfo item in Entity.GetType().GetProperties())
                {
                    row.Add(item.Name, item.GetValue(Entity, null));
                }
                rows.Add(row);
            }

            var RealRows = rows.ToList();


            Console.ReadKey();
        }
    }


    public class Person
    {

        public Person()
        {

        }

        public Person(string Sex)
        {
            this.Sex = Sex;
        }

        public int Id { get; set; }

        public string Name { get; set; }

        public string Sex { get; set; }

        public DateTime Birthday { get; set; }

        public int Height { get; set; }

        public int Weight { get; set; }

    }

}
